function main() {
  // 核心音乐播放对象
  const AudOb = new Audio();
  GroupVariable.AudOb = AudOb;
  // 描述模式flager
  let figlMod = GroupEnum.ModEnum.RANDOM_NETMUSIC;
  // 输入框元素(搜索)
  const inputElemOf = document.querySelector("#searinput");
  // 搜索词保存
  let tempSear = "";

  // 对模块加载完成进行监听
  document.body.addEventListener("moduleInited", (event) => {
    event.stopPropagation();
    event.preventDefault();
    mui.toast("Welcome~  今天是KiteMusic陪伴你的第x天~");
    const swiper = new Swiper("#colll", {
      loop: false,
      parallax: true,
      wrapperClass: "sww",
      slideClass: "ss",
      initialSlide: 1,
      allowSlidePrev: false,
      on: {
        activeIndexChange: function () {
          inputElemOf.value = "";
          ViewUtil.NavTouch.changPage(this);
        },
      },
    });
    GroupVariable.MainSwiper = swiper;
    $(".nav-core").click(function (event) {
      event.stopPropagation();
      event.preventDefault();
      let target = event.target;
      if (target.tagName.toLowerCase() == "img") {
        let ind = Number.parseInt(target.parentNode.dataset.isa);
        swiper.slideTo(ind);
      }
    });

    // 歌曲切歌功能
    const SPT = new Swiper("#tarr", {
      wrapperClass: "warr",
      slideClass: "tn",
      loop: true,
      initialSlide: 1,
      touchMoveStopPropagation: true,
      on: {
        // 点击双击事件
        click: function (swiper, event) {
          ViewUtil.MusicColl.MPlayer(true);
          ViewUtil.Rond.rondMPlayer(null,AudOb);
          if (GroupVariable.SelfPageId == 1) {
            GroupVariable.SelfPageId = 3;
          } else {
            GroupVariable.SelfPageId = 2;
          }
        },
        doubleClick: function (swiper, event) {
          console.log(event);
          mui.toast("暂不支持收藏功能");
        },
        // 滑动事件
        slideChangeTransitionEnd: function () {
          GroupVariable.PlayIndex = this.realIndex;
          if (this.swipeDirection == "next") {
            if(GroupVariable.PlayMod == GroupEnum.PlayerMod.RAND_LOOP){
              if(figlMod == GroupEnum.ModEnum.QQ_MUSIC){
                let randoms = AppUtil.Random.getNumber(0,GroupVariable.QQMusicData.length - 1);
                GroupVariable.NowMusicId = randoms;
              }else{
                let random_num = AppUtil.Random.getNumber(0,GroupVariable.saveParseData.length - 1);
                GroupVariable.NowMusicId = random_num;
              }
            }
            AppUtil.Select.slem(AudOb, this, figlMod);
            $('.mcc-pp > img').attr('src','icons/play.svg');
          } else {
            AppUtil.Select.priv(AudOb, this, figlMod);
          }
        },
      },
    });

    // 歌曲列表对象
    const SLSwiper = new Swiper('#musicListSwiper',{
      wrapperClass : 'music_list_wrapper',
      slideClass : 'music_list_slide',
      effect : 'coverflow',
      slidesPerView: 3,
      centeredSlides: true,
      coverflowEffect: {
        rotate: 30,
        stretch: 10,
        depth: 60,
        modifier: 2,
        slideShadows : true
      },
      on : {
        // 点击切换歌曲
        click(swiper,event){
          let id = swiper.activeIndex;
          // 判断模式
          switch(figlMod){
            // QQ音乐
            case GroupEnum.ModEnum.QQ_MUSIC:
              GroupVariable.IsInitNextM = false;
              GroupVariable.NextMusicData = null;
              let data = GroupVariable.QQMusicData[id];
              GroupVariable.NowMusicId = id;
              AudOb.src = data.url;
              AudOb.play();
              ViewUtil.MusicColl.updataSM(data.song, data.img,AudOb,data.singer);
              ViewUtil.MusicColl.roat(true);
              break;
            // 搜索歌曲
            case GroupEnum.ModEnum.SEARCH_LIST:
              AppUtil.Music.updateNetGet(id + 1,tempSear,AudOb);
              // 渲染数据
              let datas = new Array();
              GroupVariable.searchTemp.forEach((data, index) => {
                let temp = GroupVariable.saveParseData[index];
                if (temp != null) {
                  datas.push(temp);
                  return;
                }
                datas.push({
                  title: data.title,
                  singer: data.singer,
                  cover: "images/icon/netmusic.png",
                });
              });
              ViewUtil.Rond.rondMList(datas, figlMod);
              GroupVariable.PlayListSwiper.slideTo(GroupVariable.NowMusicId,1);
              break;
            // 正常处理
            case GroupEnum.ModEnum.RANDOM_NETMUSIC:
            case GroupEnum.ModEnum.SLEEP_MUSIC:
              GroupVariable.NowMusicId = id;
              let datae = GroupVariable.MusicList[GroupVariable.NowMusicId];
              AudOb.src = datae.url;
              AudOb.play();
              ViewUtil.MusicColl.updataSM(datae.song, datae.img,AudOb,datae.singer);
              ViewUtil.MusicColl.roat(true);
              ViewUtil.Rond.rondSName(datae.song,GroupVariable.MusicList[GroupVariable.NowMusicId + 1].song,datae.singer);
              GroupVariable.PlayListSwiper.slideTo(GroupVariable.NowMusicId,1);
              break;
          }
        }
      }
    });
    GroupVariable.PlayListSwiper = SLSwiper;

    // 全屏歌曲播放页事件监听
    $('.mcc-up > img').click(function(){
      AppUtil.Select.priv(AudOb, this, figlMod);
      $('.mcc-pp > img').attr('src','icons/play.svg');
    });
    $('.mcc-down > img').click(function(){
      if(GroupVariable.PlayMod == GroupEnum.PlayerMod.RAND_LOOP){
        if(figlMod == GroupEnum.ModEnum.QQ_MUSIC){
          let randoms = AppUtil.Random.getNumber(0,GroupVariable.QQMusicData.length - 1);
          GroupVariable.NowMusicId = randoms;
        }else{
          let random_num = AppUtil.Random.getNumber(0,GroupVariable.saveParseData.length - 1);
          GroupVariable.NowMusicId = random_num;
        }
      }
      AppUtil.Select.slem(AudOb, this, figlMod);
      $('.mcc-pp > img').attr('src','icons/play.svg');
    });
    $('.mcc-mod > img').click(function(){
      switch(GroupVariable.PlayMod){
        // 列表循环
        case GroupEnum.PlayerMod.LIST_LOOP:
          if(figlMod == GroupEnum.ModEnum.RANDOM_NETMUSIC || figlMod == GroupEnum.ModEnum.SLEEP_MUSIC){
            GroupVariable.PlayMod = GroupEnum.PlayerMod.DC_LOOP;
            $('.mcc-mod > img').attr('src','icons/dc_loop.svg');
          }else{
            GroupVariable.PlayMod = GroupEnum.PlayerMod.RAND_LOOP;
            $('.mcc-mod > img').attr('src','icons/rand_loop.svg');
          }
          break;
        // 随机列表
        case GroupEnum.PlayerMod.RAND_LOOP:
          GroupVariable.PlayMod = GroupEnum.PlayerMod.DC_LOOP;
          $('.mcc-mod > img').attr('src','icons/dc_loop.svg');
          break;
        // 单曲循环
        case GroupEnum.PlayerMod.DC_LOOP:
          GroupVariable.PlayMod = GroupEnum.PlayerMod.LIST_LOOP;
          $('.mcc-mod > img').attr('src','icons/list_loop.svg');
          break;
      }
    });
    // 展示歌曲列表
    $('.mcc-list > img').click(function(event){
      $('.mpa-define').fadeOut();
      $('.mpa-select').fadeIn();
      GroupVariable.PlayListSwiper.slideTo(GroupVariable.NowMusicId,1);
      if(GroupVariable.SelfPageId == 2){
        GroupVariable.SelfPageId = 4;
      }else{
        GroupVariable.SelfPageId = 5;
      }
    });

    // 模式选择
    $(".box-ses").click(function (event) {
      let target = event.target;
      let tagname = target.tagName.toLowerCase();
      if (target.dataset.car == "searchmod") {
        swiper.allowSlidePrev = true;
        swiper.slideTo(0);
        $(".qq-page").css("display", "none");
        $(".search-page").css("display", "block");
        GroupVariable.SelfPageId = 1;
        return;
      }
      if (ViewUtil.MusicColl.isAnimeing) return;
      if (tagname == "img") {
        target = target.parentNode;
        let car = target.dataset.car;
        switch (car) {
          // 随机网易云处理
          case "netmusic":
            GroupVariable.MusicList = [];
            GroupVariable.NowMusicId = 0;
            GroupVariable.IsInitNextM = false;
            AppUtil.Music.fetNetMusic(AudOb, SPT);
            figlMod = GroupEnum.ModEnum.RANDOM_NETMUSIC;
            $(".net").addClass("showThis");
            $(".sleep").removeClass("showThis");
            $(".qqmus").removeClass("showThis");
            $(".searchm").removeClass("showThis");
            if(GroupVariable.PlayMod == GroupEnum.PlayerMod.RAND_LOOP){
              $('.mcc-mod > img').click();
            }
            ViewUtil.Rond.rondMList(GroupVariable.MusicList,figlMod);
            break;
          // 随机助眠处理
          case "sleepmusic":
            GroupVariable.MusicList = [];
            GroupVariable.NowMusicId = 0;
            GroupVariable.IsInitNextM = false;
            AppUtil.Music.fetSleepMusic(AudOb, SPT);
            figlMod = GroupEnum.ModEnum.SLEEP_MUSIC;
            $(".sleep").addClass("showThis");
            $(".net").removeClass("showThis");
            $(".qqmus").removeClass("showThis");
            $(".searchm").removeClass("showThis");
            if(GroupVariable.PlayMod == GroupEnum.PlayerMod.RAND_LOOP){
              $('.mcc-mod > img').click();
            }
            ViewUtil.Rond.rondMList(GroupVariable.MusicList,figlMod);
            break;
          // 随机QQ音乐处理
          case "qqmusic":
            swiper.allowSlidePrev = true;
            swiper.slideTo(0);
            GroupVariable.SelfPageId = 1;
            $(".search-page").css("display", "none");
            $(".qq-page").css("display", "block");
            if (GroupVariable.QQMusicData == null) {
              AppUtil.Music.fetQQMusic();
            }
            break;
          // 搜索音乐
          case "searchmod":
            swiper.allowSlidePrev = true;
            swiper.slideTo(0);
            GroupVariable.SelfPageId = 1;
            $(".qq-page").css("display", "none");
            $(".search-page").css("display", "block");
            break;
        }
      }
    });

    // 对音乐结束进行监听处理
    AudOb.addEventListener("ended", (event) => {
      event.stopPropagation();
      event.preventDefault();
      switch(GroupVariable.PlayMod){
        case GroupEnum.PlayerMod.LIST_LOOP:
          AppUtil.Select.slem(AudOb, SPT, figlMod);
          break;
        case GroupEnum.PlayerMod.RAND_LOOP:
          switch (figlMod) {
            case GroupEnum.ModEnum.QQ_MUSIC:
              let randoms = AppUtil.Random.getNumber(0,GroupVariable.QQMusicData.length - 1);
              GroupVariable.NowMusicId = randoms;
              AppUtil.Select.slem(AudOb, SPT, figlMod);
              break;
            case GroupEnum.ModEnum.SEARCH_LIST:
              let random_num = AppUtil.Random.getNumber(0,GroupVariable.saveParseData.length - 1);
              GroupVariable.NowMusicId = random_num;
              AppUtil.Select.slem(AudOb, SPT, figlMod);
              break;
          }
          break;
        case GroupEnum.PlayerMod.DC_LOOP:
          AudOb.play();
          break;
      }
    });

    // 对搜索模式做监听
    $('.toggle-coll > img').click(function (event) {
      if(GroupVariable.tempSear != ''){
        inputElemOf.value = GroupVariable.tempSear;
      }
      if(GroupVariable.searchMod == GroupEnum.SearchMod.NetEasyMusic){
        GroupVariable.searchMod = GroupEnum.SearchMod.QiShuiMusic;
        $('.toggle-coll > img').attr('src','icons/qishui.svg');
        $(".sear-coll > img").click();
        return;
      }
      GroupVariable.searchMod = GroupEnum.SearchMod.NetEasyMusic;
      $('.toggle-coll > img').attr('src','icons/wangyiyun.svg');
      $(".sear-coll > img").click();
    });

    // 对搜索监听处理
    $(".sear-coll > img").click(function (event) {
      if (inputElemOf.value == "") return;
      tempSear = inputElemOf.value;
      GroupVariable.tempSear = tempSear;
      if(GroupVariable.searchMod == GroupEnum.SearchMod.NetEasyMusic){
        // 网易云
        AppUtil.SraechOf.NetMusic(tempSear);
      }else{
        // 汽水
        AppUtil.SraechOf.QSMusic(tempSear);
      }
      
    });
    inputElemOf.addEventListener("keydown", (event) => {
      if (event.keyCode == 13) {
        $(".sear-coll > img").click();
      }
    });
    // 搜索歌曲列表点击
    $(".sear-list-coll").click(function (event) {
      event.stopPropagation();
      event.preventDefault();
      let target = event.target;
      let tagname = target.tagName.toLowerCase();
      let n = 0;
      if (tagname == "div") {
        n = Number.parseInt(target.dataset.n);
      } else {
        n = Number.parseInt(target.parentNode.dataset.n);
      }
      if (Number.isNaN(n)) return false;
      if (figlMod != GroupEnum.ModEnum.SEARCH_LIST) {
        $(".net").removeClass("showThis");
        $(".sleep").removeClass("showThis");
        $(".qqmus").removeClass("showThis");
        $(".searchm").addClass("showThis");
      }
      GroupVariable.MusicList = [];
      figlMod = GroupEnum.ModEnum.SEARCH_LIST;
      AppUtil.Music.updateNetGet(n,tempSear,AudOb);
      // 渲染数据
      let datas = new Array();
      GroupVariable.searchTemp.forEach((data, index) => {
        let temp = GroupVariable.saveParseData[index];
        if (temp != null) {
          datas.push(temp);
          return;
        }
        datas.push({
          title: data.title,
          singer: data.singer,
          cover: "images/icon/netmusic.png",
        });
      });
      ViewUtil.Rond.rondMList(datas, figlMod);
    });

    // QQ切歌
    $(".qqm-coll").click(function (event) {
      event.stopPropagation();
      event.preventDefault();
      let target = event.target;
      let tagname = target.tagName.toLowerCase();
      let n = 0;
      if (tagname == "img" || tagname == "span" || tagname == "p") {
        target = target.parentNode;
        tagname = "div";
      }
      if (tagname == "div" && target.className == "qq-music-coll") {
        if(figlMod != GroupEnum.ModEnum.QQ_MUSIC){
          GroupVariable.MusicList = GroupVariable.QQMusicData;
          ViewUtil.Rond.rondMList(GroupVariable.MusicList,figlMod);
          $(".net").removeClass("showThis");
          $(".sleep").removeClass("showThis");
          $(".searchm").removeClass("showThis");
          $(".qqmus").addClass("showThis");
        }
        GroupVariable.IsInitNextM = false;
        GroupVariable.NextMusicData = null;
        n = Number.parseInt(target.dataset.n);
        let data = GroupVariable.QQMusicData[n];
        GroupVariable.NowMusicId = n;
        figlMod = GroupEnum.ModEnum.QQ_MUSIC;
        AudOb.src = data.url;
        AudOb.play();
        ViewUtil.MusicColl.updataSM(data.song, data.img,AudOb,data.singer);
        ViewUtil.MusicColl.roat(true);
      }
    });

    // 处理音乐进度条
    let audLeng;
    let audEnd;
    let step;
    let donef = false;
    let porsur = false;
    let timer = setInterval(() => {}, 999999999);
    let timec = setTimeout(() => {},999999999);
    let ni = 0;
    const PROGELEM = layui.slider.render({
      elem: "#LoadProgFoor",
      max: 1000,
      tips: false,
      theme : '#31bdec',
      done: function (value) {
        if (donef) return;
        porsur = false;
        let temp = audLeng;
        if (!AudOb.src) {
          this.value = 0;
          return;
        }
        let neop = step * value;
        if (neop >= temp) {
          ni += Math.floor((neop - temp) / step);
        } else {
          ni -= Math.floor((temp - neop) / step);
        }
        AudOb.currentTime = neop * 0.001;
      },
    });

    // 处理音乐进度条
    new MutationObserver((mutations) => {
      mutations.forEach((mutation) => {
        if (mutation.type == "attributes" && mutation.attributeName == "src") {
          // 对音乐载入作监听
          clearInterval(timer);
          clearTimeout(timec);
          ni = 0;
          // 不好的实现,待优化
          timec = setTimeout(() => {
            audLeng = Number.parseInt(AudOb.currentTime * 1000);
            audEnd = Number.parseInt(AudOb.duration * 1000);
            step = Number.parseInt(audEnd / 1000);
            timer = setInterval(() => {
              // 10ms精度
              if(!AudOb.paused) ni++;
              if(porsur) return;
              audLeng = Number.parseInt(AudOb.currentTime * 1000);
              donef = true;
              PROGELEM.setValue(ni);
              donef = false;
            }, step);
          },GroupEnum.ResetData.NOM);
        }
      });
    }).observe(AudOb, {
      attributes: true,
      attributeFilter: ["src"],
    });
    // 黑科技,保证长时间滑动进度条不出问题
    $('.layui-slider-wrap-btn').on('touchstart mousedown',function(event){
      porsur = true;
    });

    // 修正数据
    setInterval(() => {
      if (AudOb.paused) return;
      if (porsur) return;
      let leng = Number.parseInt(AudOb.currentTime * 1000);
      ni = Math.ceil(leng / step);
      // TODO...
    }, GroupEnum.ResetData.NOM);

    // 对Audio做监听
    AudOb.addEventListener("pause",(event) => {
      $(".mus-kbd > img").attr("src", "icons/pause.svg");
      ViewUtil.MusicColl.roat(false);
    });
    AudOb.addEventListener("play",(event) => {
      $(".mus-kbd > img").attr("src", "icons/play.svg");
      ViewUtil.MusicColl.roat(true);
    });
  });

  // 小音乐监听
  $(".mus-kbd > img,.mcc-pp > img").click(function (event) {
    if (AudOb.paused) {
      AudOb.play();
    } else {
      AudOb.pause();
    }
    if (event.target.className.toLowerCase() == 'happy-happy-happy') {
      ViewUtil.Rond.rondMPlayer(null,AudOb);
    }
  });

  // 对屏幕旋转进行监听
  window.addEventListener("orientationchange", (event) => {
    event.stopPropagation();
    event.preventDefault();
    // 待办...
  });

  // 随机加载图片
  let uri = "url(images/starter/" + AppUtil.Random.getNumber(0, 5) + ".png)";
  $(".application-load").css("background-image", uri);
  $(".application-core").css("background-image", uri);

  // 一些可以处理的任务于此
  $(".back-btn > img").click(function (event) {
    return onBackPressed();
  });
  AppUtil.Music.fetQQMusic(false);
}

// 这里对返回键进行监听
function onBackPressed() {
  // 等待资源初始化成功
  if (GroupStatic.coreInited) {
    switch (GroupVariable.SelfPageId) {
      // 左侧页面展开为一
      case 1:
        GroupVariable.MainSwiper.slideTo(1);
        GroupVariable.SelfPageId = 0;
        break;
      // 未展开为2处理
      case 2:
        ViewUtil.MusicColl.MPlayer(false);
        GroupVariable.SelfPageId = 0;
        break;
      // 展开为3处理
      case 3:
        ViewUtil.MusicColl.MPlayer(false);
        GroupVariable.SelfPageId = 1;
        break;
      // 未展开为2处理--
      case 4:
        $('.mpa-select').fadeOut();
        $('.mpa-define').fadeIn();
        GroupVariable.SelfPageId = 2;
        break;
      // 展开为3处理 --
      case 5:
        $('.mpa-select').fadeOut();
        $('.mpa-define').fadeIn();
        GroupVariable.SelfPageId = 3;
        break;
      // 兜底处理代码
      default:
        ViewUtil.MusicColl.MPlayer(false);
        GroupVariable.MainSwiper.slideTo(1);
        GroupVariable.SelfPageId = 0;
        break;
    }
    // 待办...
  }
}
$(main);
